<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>{$meta_title}</h2>
    </div>

    <div class="cf">
        <a class="btn" href="{:U('add')}">新 增</a>
        <button class="btn ajax-post" url="{:U('setStatus', ['status'=>1])}" target-form="ids" autocomplete="off">启 用</button>
        <button class="btn ajax-post" url="{:U('setStatus', ['status'=>0])}" target-form="ids" autocomplete="off">禁 用</button>
        <button class="btn ajax-post" url="{:U('setStatus', ['status'=>-1])}" target-form="ids" autocomplete="off">删 除</button>
        <!-- 高级搜索 -->
        <!--<div class="search-form fr cf">
            <div class="sleft">
                <input type="text" name="title" class="search-input" value="{:I('title')}" placeholder="请输入菜单名称">
                <a class="sch-btn" href="javascript:;" id="search" url="__SELF__"><i class="btn-search"></i></a>
            </div>
        </div>-->
    </div>

    <div class="data-table table-striped">
        <form class="ids">
            <table>
                <thead>
                <tr>
                    <th class="row-selected">
                        <input class="checkbox check-all" type="checkbox">
                    </th>
                    <th>Id</th>
                    <th>名称</th>
                    <th>描述</th>
                    <th>类型</th>
                    <th>栏目</th>
                    <th>唯一标志</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <notempty name="list">
                    <volist name="list" id="item">
                        <?php
                            $advertise_type_list = Common\Model\AdvertisePositionModel::getAdvertiseTypeList();
                            $item['type_title'] = $advertise_type_list[$item['type']]['title'];
                            $item['category_title'] = get_category_title($item['category_id']);
                            $item['status_title'] = get_status_title($item['status']);
                        ?>
                        <tr>
                            <td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$item.id}"></td>
                            <td>{$item.id}</td>
                            <td>
                                {$item.title}
                            </td>
                            <td>{$item.description}</td>
                            <td>{$item.type}</td>
                            <td>{$item.category_title}</td>
                            <td>{$item.only_sign}</td>
                            <td>{$item.status_title}</td>
                            <td>
                                <a title="编辑" href="{:U('edit?id='.$item['id'])}">编辑</a>
                                <a href="{:U('AdvertiseData/index', ['position_id'=>$item['id']])}" >广告列表</a>
                            </td>
                        </tr>
                    </volist>
                    <else/>
                    <td colspan="10" class="text-center"> aOh! 暂时还没有内容! </td>
                </notempty>
                </tbody>
            </table>
        </form>
        <!-- 分页 -->
        <div class="page">

        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function() {
            //搜索功能
            $("#search").click(function() {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //导航高亮
            highlight_subnav("{:U('index')}");
            //点击排序
            $('.list_sort').click(function(){
                var url = $(this).attr('url');
                var ids = $('.ids:checked');
                var param = '';
                if(ids.length > 0){
                    var str = new Array();
                    ids.each(function(){
                        str.push($(this).val());
                    });
                    param = str.join(',');
                }

                if(url != undefined && url != ''){
                    window.location.href = url + '/ids/' + param;
                }
            });
        });
    </script>
</block>